<?php
class Admin_Form_Company extends Zend_Form
{

    public function init()
    {
        $this->setName("admin");

        $comId = new Zend_Form_Element_Hidden('comId');
        $comId->addFilter('Int');                              

        $userFreeCom = new Zend_Form_Element_Select('userId');
        $userFreeCom->setLabel('Tài khoản sở hữu');
        $modelUser = new Admin_Model_User();
        $userFreeComList = $modelUser->getUserFreeCom();
        $userFreeCom->addMultiOption('0','--- D.Nghiệp tự do ---');
        foreach ($userFreeComList as $user) {
            $userFreeCom->addMultiOption($user['userId'],$user['email']);
        }
        
        $fullname = new Zend_Form_Element_Text('fullname');
        $fullname->setLabel('Tên công ty (*)')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $fullname->setAttrib('size', 60);
        
        $contact = new Zend_Form_Element_Text('contact');
        $contact->setLabel('T.Tin Liên hệ (*)')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $contact->setAttrib('size', 60);

        $phone = new Zend_Form_Element_Text('phone');
        $phone->setLabel('Điện thoại liên hệ (*)')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $phone->setAttrib('size', 20);

        $website = new Zend_Form_Element_Text('website');
        $website->setLabel('Website')->addFilter('StripTags')->addFilter('StringTrim');
        $website->setAttrib('size', 60)->setAttrib('placeholder','http://');
        
        $address = new Zend_Form_Element_Text('address');
        $address->setLabel('Địa chỉ')->addFilter('StripTags')->addFilter('StringTrim');
        $address->setAttrib('size', 60);
        
        $tax = new Zend_Form_Element_Text('tax');
        $tax->setLabel('Mã số thuế')->addFilter('StripTags')->addFilter('StringTrim');
        $tax->setAttrib('size', 60);
        
        $fax = new Zend_Form_Element_Text('fax');
        $fax->setLabel('Số fax')->addFilter('StripTags')->addFilter('StringTrim');
        $fax->setAttrib('size', 60);
        
        $mobile = new Zend_Form_Element_Text('mobile');
        $mobile->setLabel('Di động')->addFilter('StripTags')->addFilter('StringTrim');
        $mobile->setAttrib('size', 60);
                        
        $logo =new Zend_Form_Element_File('logo');                        
        $logo->setLabel('Thay đổi Logo');                          
        $logo->addValidator('Extension',true,array('jpg','gif','png'),'picture');                 
        $logo->addValidator('Size',true,array('min'=>'0KB','max'=>'5KB'),'picture');
        $logo->setAttrib('size', 60);
        
        $email = new Zend_Form_Element_Text('email');
        $email->setLabel('Email')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('EmailAddress');
        $email->setAttrib('size', 60);
        
        $skype = new Zend_Form_Element_Text('skype');
        $skype->setLabel('Nick Skype')->addFilter('StripTags')->addFilter('StringTrim');
        $skype->setAttrib('size', 60);
        
        $yahoo = new Zend_Form_Element_Text('yahoo');
        $yahoo->setLabel('Nick Yahoo')->addFilter('StripTags')->addFilter('StringTrim');
        $yahoo->setAttrib('size', 60);
                                      
        $intro = new Zend_Form_Element_Textarea('intro');
        $intro->setLabel('Giới thiệu')->addFilter('StringTrim');        
                                                
        // submit button
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setAttrib('id','submitbutton');
        $submit->setAttrib('class',"button medium");
                
        // add elements to form
        $this->addElements(array (
            $comId, $userFreeCom, $fullname, $contact, $phone, $fax, $mobile, $email, $address, $tax, $website, $logo, $skype, $yahoo, $intro, $submit
        ));
    }
}

